def BubbleSort(a):
    for i in range(0, len(a) - 1):
        for j in range(len(a) - 1, i, -1):
            if a[j] < a[j - 1]:
                temp = a[j]
                a[j] = a[j - 1]
                a[j - 1] = temp

    print(a)

    pass


def BubbleSort2(a):
    flag = True
    while flag == True:
        for i in range(0, len(a) - 1):
            for j in range(len(a) - 1, i, -1):
                flag = False
                if a[j] < a[j - 1]:
                    temp = a[j]
                    a[j] = a[j - 1]
                    a[j - 1] = temp
                    flag = True

    print(a)

    pass


a = [3, 8, 7, 9, 0, 3, 1, 2]
print(a)
BubbleSort2(a)
